class Solution(object):
    def timeRequiredToBuy(self, tickets, k):
        n = len(tickets)
        ans = tickets[k]
        for i in range(k):
            ans += min(tickets[i], tickets[k])
        for i in range(k + 1, n):
            ans += min(tickets[i], tickets[k] - 1)
        return ans